Skip to content

Snapcraft: Update Java example to use core22 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
degville opened this issue Jan 25, 2024 · 15 comments · Fixed by #45
Closed

Snapcraft: Update Java example to use core22 #5

degville opened this issue Jan 25, 2024 · 15 comments · Fixed by #45
Assignees
Labels
help wanted We welcome community help with this issue how-to Create a edit a how-to to achieve a specific task size 5 Fix a known documentation issue (size 5/8) update Update potentially outdated instructions, commands, or version numbers

Comments

@degville
Copy link
Collaborator

degville commented Jan 25, 2024

Update the following how-to guide to use core22 (or core24):

https://snapcraft.io/docs/java-applications

This file has been moved to this repository

Background

Snapcraft's platform quickstart how-to guides help snap developers create a first snap with their chosen framework or development environment. Many of these guides become out of date and need to be revised. Specifically, they may need to be updated to address the following:

  • update the core snap to the latest supported (such as from core18 to core22)
  • an updated core will typically require changes to the associated plugin
  • replace an inappropriate or no longer relevant example

Prerequisites

You will need some experience building snaps, and some knowledge of the target framework or development environment.

See also Contribute to our documentation.

@degville degville added help wanted We welcome community help with this issue size 5 Fix a known documentation issue (size 5/8) how-to Create a edit a how-to to achieve a specific task update Update potentially outdated instructions, commands, or version numbers labels Jan 25, 2024
@adityasamant25
Copy link
Contributor

Hi,
I am interested in working on this issue. I'm first trying my hand at executing the current instructions in this guide.
Once I am able to complete the setup on my machine, I'd be in a better position to provide an estimate of task completion.

@adityasamant25
Copy link
Contributor

The current guide uses the following example repository:
https://github.com/merlijn-sebrechts/freeplane-1

The snapcraft.yaml file present here is dependent on the gradle plugin.

However, as mentioned in the Supported plugins page and the Gradle plugin page, the gradle plugin is only available to core and core18 based snaps.

Which means it is not supported for core22, and as such it results in an error when running the snapcraft command with core22 as base.

2024-03-20 18:59:01.897 Bad snapcraft.yaml content:
- plugin not registered: 'gradle' (in field 'parts.freeplane')

It seems the Freeplane application needs gradle to be built.

I will need some inputs on how to proceed with this, as it seems like a blocker to progress.

@adityasamant25
Copy link
Contributor

Hi @degville
I'd love to hear your thoughts on this.

Kind regards,
Aditya

@degville
Copy link
Collaborator Author

Hello @adityasamant25. Sorry for the delay getting back to you on this. I was on holiday last week, and just go back to today. And thank you so much for the hard work you've already put into investigating the issue.

It looks like we may need to use a different plugin for a Java project, and it looks like the best approach might be to find a project using maven. This has been added to core22, and I'd start by searching GitHub for examples that use both core22 and maven, to see if any can be adapted for this guide. The search for doing this might look something like https://github.com/search?q=path%3A**%2Fsnapcraft.yaml+maven+core22&type=code.

I can see now this is a big task! I'd be happy to look for a better example myself and suggest one - it may just take me a little time, so also feel free to try out any of the projects that look suitable (if you also have the time!). For now, I'll assign the task to you as you've already put substantial effort into this and we can perhaps both look into better example maven-based projects.

@adityasamant25
Copy link
Contributor

Thank you @degville for your inputs.
Indeed, moving to a project using maven seems the best approach for now.
I'll try to look into an existing project that could be used. I do not have much experience creating snaps, but if I get the time I'll also try my hands at building a simple spring boot based Java project and create a snap for it.

@adityasamant25
Copy link
Contributor

Hi @degville,
The following project builds successfully with a core22 base and a maven plugin.
https://github.com/frossm/cal

I have tested it using the following steps:

  1. Create a new Ubuntu VM using multipass.
    multipass launch --disk 10G --memory 3G --cpus 2 --name playground jammy

  2. SSH into the VM
    multipass shell playground

  3. Clone the repository:
    git clone https://github.com/frossm/cal.git

  4. Install snapcraft:
    sudo snap install snapcraft --classic

  5. Initialize LXD:
    lxd init --auto

  6. Enter the cal directory:
    cd cal

  7. Run the snapcraft command:
    snapcraft

  8. Install the snap locally:
    sudo snap install fcal_*.snap --devmode --dangerous

  9. Run the snap:
    fcal

This shows a calendar on screen, confirming that the snap ran successfully.

  1. Removed the snap:
    sudo snap remove

Important points to note:

  1. On my previous VM, I had docker installed. This conflicted with the LXD networking as described here

  2. I did not fully test the publish and upload of the snap as the registration of the name takes some time.

  3. We need to decide if this app can serve as a good example for this 'how-to' guide.

If it seems like a good example, I can start working on the actual document changes.

Awaiting your feedback.

Kind regards,
Aditya

@degville
Copy link
Collaborator Author

@adityasamant25 That looks perfect. Thank you so much for looking into this so deeply, and well done getting the snap to build. I think it's a great example. Please feel free to modify the how-to using this project as a base - don't worry about the publishing part.

@adityasamant25
Copy link
Contributor

@degville Do I need to modify the document in the Discourse forum present here?
https://forum.snapcraft.io/t/java-applications/7819

@degville
Copy link
Collaborator Author

@degville Do I need to modify the document in the Discourse forum present here? https://forum.snapcraft.io/t/java-applications/7819

Good question, and I'm sorry I didn't address this in the issue itself. If you feel comfortable editing that document, then yes - by all means, please go ahead. That's how we usually work with those documents. Equally, if you prefer, I don't mind moving the doc to this repository where you may want to create a pull request. Either way works.

@adityasamant25
Copy link
Contributor

I'm much more comfortable working via pull requests. If you can please move the document as a .md file in the open-documentation-academy repository, that would be great.

@degville
Copy link
Collaborator Author

If you can please move the document as a .md file in the open-documentation-academy repository, that would be great.

@adityasamant25 More than happy to. As you've probably already seen, you can now find this file in the repository:
https://github.com/canonical/open-documentation-academy/blob/main/snapcraft/how-to/java-applications/java-applications.md

@adityasamant25
Copy link
Contributor

@degville Thank you. I will begin work on this today. I'll try to raise a PR before 2nd April.

@degville
Copy link
Collaborator Author

@adityasamant25 Thanks for the estimate - I don't think I'll be able to look at anything before the 6th April, so please don't feel like there's any rush. Also, feel free to be bold with that document (or not!). There's a lot of boiler-plate text in there that's copied across those old how-tos, and you may not feel the text is necessary or effective. Just cut it or replace it, as you see fit. And thanks again for looking at this.

@adityasamant25
Copy link
Contributor

@degville I have created a PR for this issue. #45

@degville
Copy link
Collaborator Author

Big thank you to @adityasamant25 for working through this issue, contributing an updated document, and migrating the document to the forum! This issue is now closed. https://forum.snapcraft.io/t/java-applications/7819/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We welcome community help with this issue how-to Create a edit a how-to to achieve a specific task size 5 Fix a known documentation issue (size 5/8) update Update potentially outdated instructions, commands, or version numbers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants